/**
 * DSM - Distributed Search Manager
 * Developed by Milspec Research International Pty Ltd
 * $Author: vhobbs $
 * $Revision: 1.4 $
 * $Date: 2007/02/26 23:46:32 $
 * (c)Copyright 2004
 * education.au limited
 * DEST
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * Neither the names education.au limited, DEST nor the names of its
 * contributors may be used to endorse or promote products derived from this
 * software without specific prior written permission.
 * To the extent permitted by law, the copyright owners of this software and
 * its contributors:
 * (i) exclude all warranties in relation to the software; and
 * (ii) exclude liability for all losses, costs, expenses and damages arising
 * in any way from the use of the software whether arising from or in
 * relation to breach of contract, negligence or any other tort, in equity
 * or otherwise. If the software is in breach of a warranty which is
 * implied by law, the copyright owners and contributors liability is
 * limited to the replacement of the software.
 *
 * @author	gsingh
 */

package au.edu.educationau.opensource.dsm.obj;

/**
 * Holds the metadata key/value pair for result items. This is useful to pass
 * across the result's non-conforming data to the web layer to allow a client to
 * use that data how they see fit. This has been shown in the VET LOR project
 * where the URL of the learning object is passed to the web layer using the
 * Result Metadata object, resulting in 0 dsm code changes.
 * 
 */

public class ResultMetadata extends java.lang.Object implements java.io.Serializable {

	private String name = "";
	private String value = "";

	/**
	 * Loaded constructor
	 * 
	 * @param name
	 *            the METADATA element name
	 * @param value
	 *            the METADATA value
	 */
	public ResultMetadata(String name, String value) {
		this.name = name;
		this.value = value;
	}

	/**
	 * Sets the name for this metadata element. Example DC.DESCRIPTION or
	 * DC.RELATION etc
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Returns the metadata element
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * Sets the metadata's value
	 * 
	 * @param value
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * Gets the metadata's value
	 */
	public String getValue() {
		return this.value;
	}

	/**
	 * Returns a formatted String version of the object, suitable for
	 * logging/debugging.
	 * 
	 * @param metadata
	 * @return
	 */
	public String formatMetadata(ResultMetadata[] metadata) {
		StringBuffer buf = new StringBuffer();
		buf.append("metadata:\n");
		if (metadata == null) {
			buf.append("NULL\n\n");
		} else {
			for (int i = 0; i < metadata.length; i++) {
				buf.append("  [" + metadata[i].getName() + ", " + metadata[i].getValue() + "]\n");
			}
		}
		return buf.toString();
	}

} // class ResultMetadata

// --EOF

